package servlet;

import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;

public class RequestListener implements ServletRequestListener,
ServletRequestAttributeListener {

	@Override
	public void attributeAdded(ServletRequestAttributeEvent arg0) {
		
		ServletRequest rquest=arg0.getServletRequest();
		String name=arg0.getName();
		Object value=arg0.getValue();
		
		System.out.println(rquest+"范围内添加 name："+name+" 值为："+value+" 的属性");


	}

	@Override
	public void attributeRemoved(ServletRequestAttributeEvent arg0) {
		ServletRequest rquest=arg0.getServletRequest();
		String name=arg0.getName();
		Object value=arg0.getValue();
		System.out.println(rquest+"范围内 name："+name+" 值为："+value+" 的属性被移除了");

	}

	@Override
	public void attributeReplaced(ServletRequestAttributeEvent arg0) {
		ServletRequest rquest=arg0.getServletRequest();
		String name=arg0.getName();
		Object value=arg0.getValue();
		System.out.println(rquest+"范围内 name："+name+" 值为："+value+" 的属性被替换了");


	}

	@Override
	public void requestDestroyed(ServletRequestEvent arg0) {
		HttpServletRequest request=(HttpServletRequest) arg0.getServletRequest();

		System.out.println("---发向"+request.getRequestURI()+"的请求被销毁了");

	}

	@Override
	public void requestInitialized(ServletRequestEvent arg0) {
		HttpServletRequest request=(HttpServletRequest) arg0.getServletRequest();

		System.out.println("---发向"+request.getRequestURI()+"的请求被初始化了");
		
	}

}
